<?php
include_once 'model/category/process.php';
include_once 'model/user/user_create.php';
$user = new users();
$fillByName = $user->FillOneByName($_SESSION);
$category = new categories();
$result = $category->FillAll();
$level_decode = json_decode($fillByName["level"], true);
?>
<div id="content">
    <?php if ($level_decode["admin"] != "" || $level_decode["create"] != "") { ?>
        <p><span class="bglinkleft"><a class="link" href="<?= $url["home"] ?>/menu/boardcreate/t/1"><?php echo $phrase["board_create"] ?></a></span></p>
    <?php } ?>
    <div style="clear: both;" ></div>
    <span class="combobox-left">
        <select name="cate_name" id="cate_name" >
            <?php
            while ($rows = mysql_fetch_array($result)) {
                ?>
                <option value="<?= $rows["category_id"] ?>"><?= $rows["category_name"] ?></option>
            <?php } ?>
        </select>
    </span>
    <div id="conten1" style="padding-top:10px"></div>

    <script type="text/javascript">
        $(document).ready(function() {
            loadData($("#cate_name").val());
            $("#cate_name").change(function(){
                var id=$(this).val();
                loadData(id);
            });
        });
    
        function loadData(id){
            var dataString = 'id='+ id + '& username=<?php echo $_SESSION["username"] ?>';
            $.ajax({
                type: "POST",
                url: "<?php echo $url["home"] ?>/model/board/board_manager.php",
                data: dataString,
                cache: false,
                success: function(html){
                    $("#conten1").html(html);
                } 
            });
        }
    </script>
</div>